package ru.evga.gwt.lib.common.client.domain;


import java.util.LinkedList;
import java.util.List;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;


public class ResultContainer<E extends BaseEntityDto>
    extends JavaScriptObject
{
    protected ResultContainer()
    {
    }

    // JSNI methods 
    public final native String isHasPrevious() /*-{
        return this.hasPrevious;
    }-*/;

    public final native String isHasNext() /*-{
        return this.hasNext;
    }-*/;

    public final native JsArray<E> getResult()/*-{
        return this.result;
    }-*/;
    
    public final List<E> getResultAsList()
    {
        LinkedList<E> result = new LinkedList<E>();
        JsArray<E> array = getResult();
        for(int i = 0; i < array.length(); i++ )
        {
            result.add(array.get(i));
        }
        return result;
    };

}
